package com.per.mybootall.test.testNewBean;

import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: yyy
 * Date: 2022/6/27
 * Time: 9:15
 * Description:当不需要单例bean的时候，同时参数很多，不想写太多构造方法的时候可以采用这种
 */
@Component
@EnableScheduling
public class test {
    @Resource
    testBean theBean;
    //@Scheduled(cron = "${schedules.upload}")
    public void testCreateObject(){

        System.out.println(JSONObject.toJSONString(theBean));

        new Thread(new Runnable() {
            @Override
            public void run() {
                testBean bean=theBean.builderBean()
                        .builderName("齐可")
                        .builderSex(1)
                        .builderAge(19);
                System.out.println(JSONObject.toJSONString(bean));
                System.out.println("bean检查："+JSONObject.toJSONString(theBean));
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                testBean bean=theBean.builderBean()
                        .builderName("齐可2号")
                        .builderSex(0)
                        .builderAge(119);
                System.out.println(JSONObject.toJSONString(bean));
                System.out.println("bean检查："+JSONObject.toJSONString(theBean));
            }
        }).start();

        System.out.println("bean检查："+JSONObject.toJSONString(theBean));

    }
}
